#!/usr/bin/env python 
# -*- coding:utf-8 -*-
import cv2, os, argparse
import numpy as np
from tqdm import tqdm
from PIL import Image


def main():
    dirs = '/root/mmdetection/data/side/train/halfimage'  # 修改你自己的图片路径
    img_file_names = os.listdir(dirs)
    m_list, s_list = [], []
    for img_filename in tqdm(img_file_names):
    # for img_filename in img_file_names:
        img = cv2.imread(dirs + '/' + img_filename)
        # img = img[75:880, 270:1750]
        # img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
        # img = img / 255.0
        m, s = cv2.meanStdDev(img)
        # print(m, s)
        m_list.append(m.reshape((3,)))
        s_list.append(s.reshape((3,)))
    m_array = np.array(m_list)
    s_array = np.array(s_list)
    m = m_array.mean(axis=0, keepdims=True)
    s = s_array.mean(axis=0, keepdims=True)
    print("mean = ", m[0][::-1])
    print("std = ", s[0][::-1])
# front
# mean = [0.26235808 0.13972785 0.01157051]
# std = [0.30289226 0.1757261  0.07702679]
# mean =  [66.901311   35.63060118  2.95047988]
# std =  [77.23752691 44.81015436 19.64183154]

# side
# mean =  [0.58824192 0.44835647 0.14391562]
# std =  [0.29236119 0.26514331 0.16147368]
# mean =  [150.00168842 114.330901    36.69848263]
# std =  [74.5521024  67.61154528 41.17578917]

if __name__ == '__main__':
    main()
